<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Director Template</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Director Template' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../extensions.html">Kits</a></li><li><a href="index.html">DialogueKit</a></li><li><b>Director Template</b></li></ul></div>
<p class="purpose">Top-level control for the Director, and how beats are selected for performance.</p>

<ul class="toc"><li><a href="drtm.html#SP1">&#167;1. Active versus inactive</a></li><li><a href="drtm.html#SP2">&#167;2. The live subject list</a></li><li><a href="drtm.html#SP3">&#167;3. Access as an Inform list</a></li><li><a href="drtm.html#SP4">&#167;4. Dialogue intervening</a></li><li><a href="drtm.html#SP5">&#167;5. Active dialogue</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Active versus inactive.</b>The most important question about the director: is it currently running in
active or inactive mode?
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">director_is_active</span><span class="plain-syntax"> = </span><span class="reserved-syntax">false</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">director_is_paused_for_command</span><span class="plain-syntax"> = </span><span class="reserved-syntax">false</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">line_performance_count</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">DirectorActivate</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">director_is_active</span><span class="plain-syntax"> = </span><span class="reserved-syntax">true</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">line_performance_count</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
<span class="plain-syntax">[ </span><span class="identifier-syntax">DirectorDeactivate</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">director_is_active</span><span class="plain-syntax"> = </span><span class="reserved-syntax">false</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. The live subject list.</b>This is stored as a null-terminated array, capped at <span class="extract"><span class="extract-syntax">DIALOGUE_MAX_LIVE_SUBJECTS</span></span>
items.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">DIALOGUE_MAX_LIVE_SUBJECTS</span><span class="plain-syntax"> = </span><span class="constant-syntax">19</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Array</span><span class="plain-syntax"> </span><span class="identifier-syntax">DialogueTopicPool</span><span class="plain-syntax"> --&gt; (</span><span class="identifier-syntax">DIALOGUE_MAX_LIVE_SUBJECTS</span><span class="plain-syntax">+1);</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">DirectorEmptyLiveSubjectList</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DialogueTopicPool</span><span class="plain-syntax">--&gt;0 = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">DirectorAddLiveSubjectList</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="identifier-syntax">o2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0:</span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">DIALOGUE_MAX_LIVE_SUBJECTS</span><span class="plain-syntax">:</span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">o2</span><span class="plain-syntax"> = </span><span class="identifier-syntax">DialogueTopicPool</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o2</span><span class="plain-syntax"> == </span><span class="identifier-syntax">obj</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o2</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=</span><span class="identifier-syntax">DIALOGUE_MAX_LIVE_SUBJECTS</span><span class="plain-syntax">-1:</span><span class="identifier-syntax">i</span><span class="plain-syntax">&gt;0:</span><span class="identifier-syntax">i</span><span class="plain-syntax">--) </span><span class="identifier-syntax">DialogueTopicPool</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="identifier-syntax">DialogueTopicPool</span><span class="plain-syntax">--&gt;(</span><span class="identifier-syntax">i</span><span class="plain-syntax">-1);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DialogueTopicPool</span><span class="plain-syntax">--&gt;0 = </span><span class="identifier-syntax">obj</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DialogueTopicPool</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">DIALOGUE_MAX_LIVE_SUBJECTS</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">DirectorRemoveLiveSubjectList</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="identifier-syntax">j</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0:</span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;=</span><span class="identifier-syntax">DIALOGUE_MAX_LIVE_SUBJECTS</span><span class="plain-syntax">:</span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">DialogueTopicPool</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">DialogueTopicPool</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax"> == </span><span class="identifier-syntax">obj</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">j</span><span class="plain-syntax">=</span><span class="identifier-syntax">i</span><span class="plain-syntax">:</span><span class="identifier-syntax">j</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">DIALOGUE_MAX_LIVE_SUBJECTS</span><span class="plain-syntax">:</span><span class="identifier-syntax">j</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">DialogueTopicPool</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">j</span><span class="plain-syntax"> = </span><span class="identifier-syntax">DialogueTopicPool</span><span class="plain-syntax">--&gt;(</span><span class="identifier-syntax">j</span><span class="plain-syntax">+1);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DialogueTopicPool</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">DIALOGUE_MAX_LIVE_SUBJECTS</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. Access as an Inform list.</b>This copies our null-terminated array into, or out of, an Inform list.
The reason we don't keep it in an Inform list all the time is that we get
very slightly faster access by not doing so, and we don't need the main
virtue of Inform lists, that is, their flexible size.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">DirectorLiveSubjectList</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">len</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">WeakKindOfPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">) ~= </span><span class="identifier-syntax">LIST_OF_TY</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">len</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">DialogueTopicPool</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">len</span><span class="plain-syntax">) </span><span class="identifier-syntax">len</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LIST_OF_TY_SetLength</span><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">, </span><span class="identifier-syntax">len</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">len</span><span class="plain-syntax">: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LIST_OF_TY_PutItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">+1, </span><span class="identifier-syntax">DialogueTopicPool</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">DirectorAlterLiveSubjectList</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">len</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">WeakKindOfPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">) ~= </span><span class="identifier-syntax">LIST_OF_TY</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">len</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">, </span><span class="identifier-syntax">LIST_LENGTH_F</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">len</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">DIALOGUE_MAX_LIVE_SUBJECTS</span><span class="plain-syntax">) </span><span class="identifier-syntax">len</span><span class="plain-syntax"> = </span><span class="identifier-syntax">DIALOGUE_MAX_LIVE_SUBJECTS</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">len</span><span class="plain-syntax">: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">DialogueTopicPool</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">, </span><span class="identifier-syntax">LIST_ITEM_BASE</span><span class="plain-syntax">+</span><span class="identifier-syntax">i</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DialogueTopicPool</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">len</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DialogueTopicPool</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">DIALOGUE_MAX_LIVE_SUBJECTS</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. Dialogue intervening.</b><span class="extract"><span class="extract-syntax">DirectorIntervenes(subj, speaker)</span></span> tries to find a beat of dialogue we can perform
which is relevant to the subject <span class="extract"><span class="extract-syntax">subj</span></span>, and returns <span class="extract"><span class="extract-syntax">true</span></span> if it did in fact
perform something, or <span class="extract"><span class="extract-syntax">false</span></span> if not (in which case it printed nothing).
If <span class="extract"><span class="extract-syntax">speaker</span></span> is not <span class="extract"><span class="extract-syntax">nothing</span></span>, then prefer beats in which that person is the
first to speak. (Note that <span class="extract"><span class="extract-syntax">speaker</span></span> will often be the player.)
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">DirectorIntervenes</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">speaker</span><span class="plain-syntax"> </span><span class="identifier-syntax">fn</span><span class="plain-syntax"> </span><span class="identifier-syntax">db</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">speaker</span><span class="plain-syntax"> ~= </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">db</span><span class="plain-syntax">=1: </span><span class="identifier-syntax">db</span><span class="plain-syntax">&lt;=</span><span class="identifier-syntax">NO_DIALOGUE_BEATS</span><span class="plain-syntax">: </span><span class="identifier-syntax">db</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">DirectorBeatFirstSpeaker</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">) == </span><span class="identifier-syntax">speaker</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">DirectorBeatAccessible</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">, </span><span class="identifier-syntax">player</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">                    (</span><span class="identifier-syntax">DirectorBeatAvailable</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">                    (</span><span class="identifier-syntax">DirectorBeatAbout</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">, </span><span class="identifier-syntax">obj</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">DirectorPerformBeat</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">db</span><span class="plain-syntax">=1: </span><span class="identifier-syntax">db</span><span class="plain-syntax">&lt;=</span><span class="identifier-syntax">NO_DIALOGUE_BEATS</span><span class="plain-syntax">: </span><span class="identifier-syntax">db</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">DirectorBeatFirstSpeaker</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">) ~= </span><span class="identifier-syntax">speaker</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">DirectorBeatAccessible</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">, </span><span class="identifier-syntax">player</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">                    (</span><span class="identifier-syntax">DirectorBeatAvailable</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">                    (</span><span class="identifier-syntax">DirectorBeatAbout</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">, </span><span class="identifier-syntax">obj</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">DirectorPerformBeat</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">db</span><span class="plain-syntax">=1: </span><span class="identifier-syntax">db</span><span class="plain-syntax">&lt;=</span><span class="identifier-syntax">NO_DIALOGUE_BEATS</span><span class="plain-syntax">: </span><span class="identifier-syntax">db</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">DirectorBeatAccessible</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">, </span><span class="identifier-syntax">player</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">                (</span><span class="identifier-syntax">DirectorBeatAvailable</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">                (</span><span class="identifier-syntax">DirectorBeatAbout</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">, </span><span class="identifier-syntax">obj</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">DirectorPerformBeat</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. Active dialogue.</b>In active mode only, the Director sometimes initiates conversation itself,
and this is the rule doing that. In passive mode the rule does nothing.
In stories with a lot of dialogue, this will run quite slowly: on the
other hand, it only has to run once in every turn, so that may not matter.
</p>

<p class="commentary">Note that the rule always succeeds, even in the case when the Director
finds nothing to perform.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">DIALOGUE_DIRECTION_R</span><span class="plain-syntax"> </span><span class="identifier-syntax">db</span><span class="plain-syntax"> </span><span class="identifier-syntax">spontaneous_one</span><span class="plain-syntax"> </span><span class="identifier-syntax">chosen_one</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">director_is_active</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">director_is_paused_for_command</span><span class="plain-syntax"> == </span><span class="reserved-syntax">false</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">director_sp</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">line_performance_count</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">db</span><span class="plain-syntax">=1: </span><span class="identifier-syntax">db</span><span class="plain-syntax">&lt;=</span><span class="identifier-syntax">NO_DIALOGUE_BEATS</span><span class="plain-syntax">: </span><span class="identifier-syntax">db</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">DirectorBeatAccessible</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">, </span><span class="identifier-syntax">player</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">                    (</span><span class="identifier-syntax">DirectorBeatAvailable</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">DirectorBeatRelevant</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">                        ((</span><span class="identifier-syntax">GProperty</span><span class="plain-syntax">(</span><span class="identifier-syntax">DIALOGUE_BEAT_TY</span><span class="plain-syntax">, </span><span class="identifier-syntax">db</span><span class="plain-syntax">, </span><span class="identifier-syntax">voluntary</span><span class="plain-syntax">) == </span><span class="reserved-syntax">false</span><span class="plain-syntax">) ||</span>
<span class="plain-syntax">                        (</span><span class="identifier-syntax">DirectorBeatFirstSpeaker</span><span class="plain-syntax">(</span><span class="identifier-syntax">db</span><span class="plain-syntax">) ~= </span><span class="identifier-syntax">player</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">chosen_one</span><span class="plain-syntax"> = </span><span class="identifier-syntax">db</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">spontaneous_one</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">                        (</span><span class="identifier-syntax">GProperty</span><span class="plain-syntax">(</span><span class="identifier-syntax">DIALOGUE_BEAT_TY</span><span class="plain-syntax">, </span><span class="identifier-syntax">db</span><span class="plain-syntax">, </span><span class="identifier-syntax">spontaneous</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">spontaneous_one</span><span class="plain-syntax"> = </span><span class="identifier-syntax">db</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">chosen_one</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">spontaneous_one</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">debug_dialogue</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">2</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"-- Active director selects spontaneous beat^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">chosen_one</span><span class="plain-syntax"> = </span><span class="identifier-syntax">spontaneous_one</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">DirectorEmptyLiveSubjectList</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">chosen_one</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">debug_dialogue</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">2</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"-- Active director selects relevant beat^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">chosen_one</span><span class="plain-syntax">) </span><span class="identifier-syntax">DirectorPerformBeat</span><span class="plain-syntax">(</span><span class="identifier-syntax">chosen_one</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">debug_dialogue</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">2</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"-- Active director cannot find a beat^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">debug_dialogue</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">2</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"-- Director is active but too much else is going on^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">line_performance_count</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprevoff">&#10094;</li><li class="progresscurrent">drtm</li><li class="progresssection"><a href="bttm.html">bttm</a></li><li class="progresssection"><a href="lntm.html">lntm</a></li><li class="progresssection"><a href="chtm.html">chtm</a></li><li class="progresssection"><a href="prtm.html">prtm</a></li><li class="progressnext"><a href="bttm.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

